package day8.homework;

import java.io.File;
import java.util.Scanner;

public class Task2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        String path = in.next();

        File file = new File(path);

        //调用一个方法递归遍历当前文件夹
        long size = calculate(file, 0);
        System.out.println(size);
    }

    private static long calculate(File file, long size) {

        if(!file.exists()) return 0;

        //获取当前文件夹下所有文件
        File[] files = file.listFiles();

        //循环
        for (File f : files) {
            //判断当前的文件路径是文件还是文件夹
            if(f.isDirectory()) {
                calculate(f, size);
            }else {
                size += f.length();
            }
        }
        return size;
    }

}
